using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Windows.Forms;
using THSLib;using THSERP.BaseProvider;
using System.Data;using THSERP.BusinessEntities;using THSERP.BaseProvider;

namespace THSERP.Modules.Report
{
    public partial class ICRP013ProductAttributesGridControl : THSGridControl
    {
        protected override void AddColumnsToGridView(string strTableName, DevExpress.XtraGrid.Views.Grid.GridView gridView)
        {
            base.AddColumnsToGridView(strTableName, gridView);

            DevExpress.XtraGrid.Columns.GridColumn col = new DevExpress.XtraGrid.Columns.GridColumn();
            col.FieldName = "ICProductDesc";
            col.Caption = "Description";
            gridView.Columns.Add(col);

            col = new DevExpress.XtraGrid.Columns.GridColumn();
            col.FieldName = "ICProductAttributeValue";
            col.Caption = "Attribute";
            gridView.Columns.Add(col);

            col = new DevExpress.XtraGrid.Columns.GridColumn();
            col.FieldName = "ICProductUnitCost";
            col.Caption = "Cost";
            col.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
            col.DisplayFormat.FormatString = "{0:n2}";
            gridView.Columns.Add(col);

            col = new DevExpress.XtraGrid.Columns.GridColumn();
            col.FieldName = "ICProductUnitPrice";
            col.Caption = "Regular Price";
            col.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
            col.DisplayFormat.FormatString = "{0:n2}";
            gridView.Columns.Add(col);
        }

        protected override DevExpress.XtraGrid.Views.Grid.GridView InitializeGridView()
        {
            DevExpress.XtraGrid.Views.Grid.GridView gridView = base.InitializeGridView();
            gridView.OptionsView.ShowFooter = true;
            gridView.OptionsBehavior.Editable = false;

            gridView.GroupFormat = "[#image]{1} {2}";
            if (gridView.Columns["FK_ICDepartmentID"] != null)
            {
                gridView.Columns["FK_ICDepartmentID"].Group();
                gridView.Columns["FK_ICProductGroupID"].Group();
            }
            return gridView;
        }

        protected override void GridView_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            DevExpress.XtraGrid.Views.Grid.GridView gridView = (DevExpress.XtraGrid.Views.Grid.GridView)sender;
            ICProductAttributesInfo objProductAttributesInfo = (ICProductAttributesInfo)gridView.GetRow(e.FocusedRowHandle);
            ((RP013)Screen).DisplayInventoryDetails(objProductAttributesInfo);
        }
    }
}
